package utility;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Log {
	private static PrintWriter pr;
	private static SimpleDateFormat date_format;
	private static String date;

	public static void write(String message) {
		create();
		pr.println(date + "  :  >>   " + message);
		pr.close();
		System.out.println("Error:  "+message);
	}

	public static void write(Exception e) {
		create();
		pr.println(date + "  :  >>   " + e.getMessage());
		pr.close();
		e.printStackTrace();
	}

	public static void create() {
		try {
			date_format = new SimpleDateFormat("yyyy-MM-dd >> hh:mm:ss");
			date = date_format.format(new Date());
			pr = new PrintWriter(new BufferedWriter(new FileWriter(new File(
					"property.log"), true)));
			pr.flush();
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

	public static void main(String[] args) {
		Log.write("Hello");
	}
}
